//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    content: [],
    userInfo: {}
  },
  //事件处理函数
  onLoad: function (options) {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    });
    that.fetchData(options.id);
  },
  fetchData:function(params){
    var that = this
    wx.request({
      url: app.URL+'/get_content_list',
      data: {
        id:params
      },
      success: function(res){
        // success
        that.setData({
          content:res.data
        })
      },
      fail: function() {
        // fail
        console.log(err);
      },
      complete: function() {
        // complete
      }
    })
  }
})
